Use geopy library to get the latitude and longitude values of Bangkok City.
address = 'Bangkok, Thailand'
geolocator = Nominatim(user_agent="foursquare_agent")
location = geolocator.geocode(address)
latitude = location.latitude
longitude = location.longitude
print(latitude, longitude)
bangkok_geo = sub_district_geojson #'bangkok_sub_district.geojson' # geojson file
# create a plain province map
bangkok_map = folium.Map(location=[latitude, longitude], zoom_start=10)
#use different map tiles (OpenStreetMap, CartoDB, Stamen, Mapbox...)
folium.TileLayer('CartoDB positron',name="Light Map",control=False).add_to(bangkok_map)
# generate choropleth map using the population of each district YlOrRd
bangkok_map.choropleth(
geo_data=bangkok_geo,
data=df_province,
columns=['sub_district_id','pop_density'],
key_on='feature.properties.sub_district_id',
fill_color='YlGnBu',
fill_opacity=0.7,
line_opacity=0.2,
legend_name='people per square meter of each sub-district'
)
# display map
#bangkok_map
style_function = lambda x: {'fillColor': '#ffffff',
'color':'#000000',
'fillOpacity': 0.1,
'weight': 0.1}
highlight_function = lambda x: {'fillColor': '#000000',
'color':'#000000',
'fillOpacity': 0.50,
'weight': 0.1}
NIL = folium.features.GeoJson(
sub_district_geojson,
style_function=style_function,
control=False,
highlight_function=highlight_function,
tooltip=folium.features.GeoJsonTooltip(
fields=['sub_district_eng','pop_density'],
aliases=['Sub-district name: ','People per square meter : '],
style=("background-color: white; color: #333333; font-family: arial; font-size: 12px; padding: 10px;")
)
)
bangkok_map.add_child(NIL)
bangkok_map.keep_in_front(NIL)
folium.LayerControl().add_to(bangkok_map)
bangkok_map